]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
StEntry: reset the cursor when unmapped
authorGiovanni Campagna <gcampagna@src.gnome.org>
Mon, 18 Feb 2013 00:47:34 +0000 (01:47 +0100)
committerGiovanni Campagna <gcampagna@src.gnome.org>
Mon, 18 Feb 2013 17:08:57 +0000 (18:08 +0100)
We cannot reset the cursor at the next leave event, as that might
happen on a NULL stage and cause a BadWindow error, so do it on
unmap (which is guaranteed to happen before the stage is cleared).

https://bugzilla.gnome.org/show_bug.cgi?id=694057

src/st/st-entry.c

index 4d0e024d311862da5b4f2add77cdb3ce00cf11c1..103b8f58c8660adc4eaa1d8429cb9e9fedf61b43 100644 (file)
@@ -109,6 +109,7 @@ struct _StEntryPrivate
 
   gboolean      hint_visible;
   gboolean      capslock_warning_shown;
+  gboolean      has_ibeam;
 };
 
 static guint entry_signals[LAST_SIGNAL] = { 0, };
@@ -667,6 +668,13 @@ st_entry_set_cursor (StEntry  *entry,
 
   dpy = clutter_x11_get_default_display ();
   stage = clutter_actor_get_stage (actor);
+
+  if (stage == NULL)
+    {
+      g_warn_if_fail (!entry->priv->has_ibeam);
+      return;
+    }
+
   wid = clutter_x11_get_stage_window (CLUTTER_STAGE (stage));
 
   if (ibeam == None)
@@ -676,6 +684,8 @@ st_entry_set_cursor (StEntry  *entry,
     XDefineCursor (dpy, wid, ibeam);
   else
     XUndefineCursor (dpy, wid);
+
+  entry->priv->has_ibeam = use_ibeam;
 }
 
 static gboolean
@@ -688,6 +698,15 @@ st_entry_crossing_event (ClutterActor         *actor,
   return FALSE;
 }
 
+static void
+st_entry_unmap (ClutterActor *actor)
+{
+  if (ST_ENTRY (actor)->priv->has_ibeam)
+    st_entry_set_cursor (ST_ENTRY (actor), FALSE);
+
+  CLUTTER_ACTOR_CLASS (st_entry_parent_class)->unmap (actor);
+}
+
 static void
 st_entry_class_init (StEntryClass *klass)
 {
@@ -706,6 +725,7 @@ st_entry_class_init (StEntryClass *klass)
   actor_class->get_preferred_width = st_entry_get_preferred_width;
   actor_class->get_preferred_height = st_entry_get_preferred_height;
   actor_class->allocate = st_entry_allocate;
+  actor_class->unmap = st_entry_unmap;
 
   actor_class->key_press_event = st_entry_key_press_event;
   actor_class->key_focus_in = st_entry_key_focus_in;